package com.twitter.home_mixer.product.for_you.model

import com.twitter.adserver.thriftscala.HomeTimelineType
import com.twitter.adserver.thriftscala.TimelineRequestParams
import com.twitter.dspbidder.commons.{thriftscala => dsp}
import com.twitter.home_mixer.model.HomeAdsQuery
import com.twitter.home_mixer.model.request.DeviceContext
import com.twitter.home_mixer.model.request.ForYouProduct
import com.twitter.home_mixer.model.request.HasDeviceContext
import com.twitter.home_mixer.model.request.HasSeenTweetIds
import com.twitter.onboarding.task.service.{thriftscala => ots}
import com.twitter.product_mixer.component_library.model.cursor.UrtOrderedCursor
import com.twitter.product_mixer.component_library.pipeline.candidate.flexible_injection_pipeline.transformer.HasFlipInjectionParams
import com.twitter.product_mixer.core.feature.featuremap.FeatureMap
import com.twitter.product_mixer.core.model.marshalling.request._
import com.twitter.product_mixer.core.pipeline.HasPipelineCursor
import com.twitter.product_mixer.core.pipeline.PipelineQuery
import com.twitter.timelines.configapi.Params

case class ForYouQuery(
  override val params: Params,
  override val clientContext: ClientContext,
  override val pipelineCursor: Option[UrtOrderedCursor],
  override val requestedMaxResults: Option[Int],
  override val debugOptions: Option[DebugOptions],
  override val features: Option[FeatureMap],
  override val deviceContext: Option[DeviceContext],
  override val seenTweetIds: Option[Seq[Long]],
  override val dspClientContext: Option[dsp.DspClientContext],
  pushToHomeTweetId: Option[Long])
  //ForYouQuery 类继承并实现了多个特质，表明它具有多种功能和特性，
// 例如处理管道游标、设备上下文、已看过的推文ID等。这
// 些特质提供了通用接口和方法，可以在不同的上下文中重复使用。
    extends PipelineQuery
    with HasPipelineCursor[UrtOrderedCursor]
    with HasDeviceContext
    with HasSeenTweetIds
    with HasFlipInjectionParams
    with HomeAdsQuery {
  override val product: Product = ForYouProduct
  //withFeatureMap: 允许向查询添加或更新特性映射。
  override def withFeatureMap(features: FeatureMap): ForYouQuery =
    copy(features = Some(features))
  //timelineRequestParams: 定义了时间线请求的参数，这里特别是针对主页时间线。
  override val timelineRequestParams: Option[TimelineRequestParams] =
    Some(TimelineRequestParams(homeTimelineType = Some(HomeTimelineType.Home)))

  // Fields below are used for FLIP Injection in Onboarding Task Service (OTS)
  //类的最后部分包含与FLIP注入相关的字段，这可能是用于在新用户加入任务服务（Onboarding Task Service，OTS）时处理特定的场景或条件。
  // 这些字段包括显示位置、排名禁用器设置、是否为空状态、是否为注册后的首次请求、是否为时间线末尾、时间线ID等。
  override val displayLocation: ots.DisplayLocation = ots.DisplayLocation.HomeTimeline
  override val rankingDisablerWithLatestControlsAvailable: Option[Boolean] = None
  override val isEmptyState: Option[Boolean] = None
  override val isFirstRequestAfterSignup: Option[Boolean] = None
  override val isEndOfTimeline: Option[Boolean] = None
  override val timelineId: Option[Long] = None
}
